﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TienIch.Utils;
namespace TienIch
{
    public partial class frmMaHoa : FormBase
    {
        public frmMaHoa()
        {
            InitializeComponent();
        }
        public static string passPhrase = "Pas5pr@se";        // can be any string
        public static string saltValue = "s@1tValue";        // can be any string
        public static string hashAlgorithm = "SHA1";             // can be "MD5"
        public static int passwordIterations = 2;                  // can be any number
        public static string initVector = "@CSS@CSS@CSS@CSS"; // must be 16 bytes
        public static int keySize = 256;
        private void btnMaHoa_Click(object sender, EventArgs e)
        {
            txtDauRa.Text =DBUtils.Encrypt(txtDauVao.Text,
                                                   passPhrase,
                                                   saltValue,
                                                   hashAlgorithm,
                                                   passwordIterations,
                                                   initVector,
                                                   keySize);
        }

        private void btnGiaiMa_Click(object sender, EventArgs e)
        {
            txtDauRa.Text = DBUtils.Decrypt(txtDauVao.Text,
                                                   passPhrase,
                                                   saltValue,
                                                   hashAlgorithm,
                                                   passwordIterations,
                                                   initVector,
                                                   keySize);
        }
    }
}
